# -*- coding: utf-8 -*-
# created on 2017/4/17

from mathsolver.functions.base import *
from mathsolver.functions.process import ProcessExpression


class VectorParaVector(BaseFunction):
    pass


class VectorGongXian(BaseFunction):
    def solver(self, *args):
        if isinstance(args[0].value, str):
            vector1 = ProcessExpression(known=self.known).solver(BasePoly(args[0].value)).output[0]
        else:
            vector1 = args[0]

        v1, v2 = vector1.sympify()
        if isinstance(args[1], BaseVector):
            if isinstance(args[1].value, str):
                vector2 = ProcessExpression(known=self.known).solver(BasePoly(args[1].value)).output[0]
            else:
                vector2 = args[1]
            v3, v4 = vector2.sympify()
        else:
            v3, v4 = args[1].sympify()[1]

        self.output.append(BaseEq([v1 * v4, v2 * v3]))
        return self


class VectorTongXiang(BaseFunction):
    def solver(self, *args):
        if isinstance(args[0].value, str):
            vector1 = ProcessExpression(known=self.known).solver(BasePoly(args[0].value)).output[0]
        else:
            vector1 = args[0]

        v1, v2 = vector1.sympify()
        if isinstance(args[1], BaseVector):
            if isinstance(args[1].value, str):
                vector2 = ProcessExpression(known=self.known).solver(BasePoly(args[1].value)).output[0]
            else:
                vector2 = args[1]
            v3, v4 = vector2.sympify()
        else:
            v3, v4 = args[1].sympify()[1]

        self.output.append(BaseIneqs([[v1 * v3, ">=", 0], [v1 * v4, v2 * v3]]))
        return self


if __name__ == '__main__':
    pass
